<?php

defined('APPS_DB_DEV_SERVER') || define('APPS_DB_DEV_SERVER',true);
defined('APPS_MCACHE_EXPIRE_TIME')|| define('APPS_MCACHE_EXPIRE_TIME',60*60*24); //memcache 失效时间
defined('APPS_MCACHE_CHANNEL_NAME')|| define('APPS_MCACHE_CHANNEL_NAME','apps'); //memcache 分配频道名


class UCConfApps
{	
	//应用类型
	const APP_TYPE_SYSTEM	= 1;
	const APP_TYPE_DEFAULT	= 2;
	const APP_TYPE_OTHERS	= 3;
	
	//系统应用	
	const APP_SYSTEM_ACCOUNT = 1;	
	const APP_SYSTEM_SET = 2;
	const APP_SYSTEM_MEDAL = 3;
	const APP_SYSTEM_TWITTER = 4;
	const APP_SYSTEM_MESSAGE = 5;
	const APP_SYSTEM_FRIEND = 6;
	const APP_UC_WEBGAME = 15;
	const APP_UC_2144 = 29;


	const APP_ERROR_PARAM			= -1;
	const APP_ERROR_INTERFACE		= -2;	
	const APP_ERROR_DB_WRITE		= -3;
	const APP_ERROR_DB_READ			= -4;
	const APP_ERROR_MC_WRITE		= -5;
	const APP_ERROR_MC_READ			= -6;
	
	//错误返回信息
	static public $arr_apps_error = array(
											self::APP_ERROR_PARAM			=> '参数传递错误',
											self::APP_ERROR_INTERFACE		=> 'APP接口错误',
											self::APP_ERROR_DB_WRITE		=> '数据库写入错误',
											self::APP_ERROR_DB_READ			=> '数据库读取错误',
											self::APP_ERROR_MC_WRITE		=> 'MC写入错误',
											self::APP_ERROR_MC_READ			=> 'MC读取错误',
										);
	
	//---------------------------by ding for test									
	//系统APP
	static public $arr_system_apps = array(	
											'1'=>array(
														'app_id' 	=> 	1,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/twitter.png',
														'app_name'	=>	'推他',
														'app_url'	=>	'/tuita',
														'app_type'	=>	1,
														'position'	=>	1,
											),
											'4'=>array(
														'app_id' 	=> 	4,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app1.png',
														'app_name'	=>	'潘多拉星球',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	4,
											),
											'5'=>array(
														'app_id' 	=> 	5,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app2.png',
														'app_name'	=>	'食物大战老鼠',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	5,
											),
											'6'=>array(
														'app_id' 	=> 	6,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app3.png',
														'app_name'	=>	'斗地主',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	6,
											),
											'7'=>array(
														'app_id' 	=> 	7,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app4.png',
														'app_name'	=>	'浪漫庄园',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	7,
											),
											'8'=>array(
														'app_id' 	=> 	8,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app5.png',
														'app_name'	=>	'僵尸大战植物人',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	8,
											),
											'9'=>array(
														'app_id' 	=> 	9,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app6.png',
														'app_name'	=>	'超市大赢家',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	9,
											),
											'10'=>array(
														'app_id' 	=> 	10,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app7.png',
														'app_name'	=>	'快乐岛主',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	10,
											),
											'11'=>array(
														'app_id' 	=> 	11,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app8.png',
														'app_name'	=>	'钻石迷城',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	11,
											),
											'12'=>array(
														'app_id' 	=> 	12,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app9.png',
														'app_name'	=>	'开唱网',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	12,
											),
											'13'=>array(
														'app_id' 	=> 	13,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app10.png',
														'app_name'	=>	'音乐节目',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	13,
											),
											'14'=>array(
														'app_id' 	=> 	14,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app1.png',
														'app_name'	=>	'棋牌游戏',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	14,
											),
											'15'=>array(
														'app_id' 	=> 	15,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/webgame.png',
														'app_name'	=>	'网页游戏',
														'app_url'	=>	'/apps/play/appid/15',
														'app_type'	=>	1,
														'position'	=>	15,														
											),
											'16'=>array(
														'app_id' 	=> 	16,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app3.png',
														'app_name'	=>	'酷六社区',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	16,
											),
											'17'=>array(
														'app_id' 	=> 	17,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app4.png',
														'app_name'	=>	'酷六视频',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	17,
											),
											'18'=>array(
														'app_id' 	=> 	18,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app5.png',
														'app_name'	=>	'酷六剧场',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	18,
											),											
											'19'=>array(
														'app_id' 	=> 	19,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app6.png',
														'app_name'	=>	'玩偶',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	19,
											),
											'20'=>array(
														'app_id' 	=> 	20,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app7.png',
														'app_name'	=>	'分红',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	20,
											),
											'21'=>array(
														'app_id' 	=> 	21,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app8.png',
														'app_name'	=>	'客服',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	21,
											),
											'25'=>array(
														'app_id' 	=> 	25,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app9.png',
														'app_name'	=>	'积分',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	25,
											),
											'26'=>array(
														'app_id' 	=> 	26,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app10.png',
														'app_name'	=>	'问吧',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	26,
											),											
											'27'=>array(
														'app_id' 	=> 	27,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app1.png',
														'app_name'	=>	'充值',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	27,
											),																						
											'28'=>array(
														'app_id' 	=> 	28,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/app2.png',
														'app_name'	=>	'测试',
														'app_url'	=>	'/apps/comingsoon',
														'app_type'	=>	1,
														'position'	=>	28,
											),																																	
											'29'=>array(
														'app_id' 	=> 	29,
														'app_icon'	=>	'http://dev.ipic.staticsdo.com/v1/images/app/2144.png',
														'app_name'	=>	'2144游戏',
														'app_url'	=>	'/apps/play/appid/29',
														'app_type'	=>	1,
														'position'	=>	29,
											),
										);
										
	//推荐APP
	static public $arr_recommend_apps = array(	
											1000000002
										);
										
										
    
	//其他apps
    static public $arr_other_apps = array(	100000008,
											1000000002
										);
	//----------------------------------test end
}





/**
* 提供统一的DB配置
* @param string $tagname DB的标识符
*/
function  apps2dbconfig($tagname,$key){

	$user        = null;
    $pass        = null;
    $port        = null;
    $table       = null;
    $table_alias = null;
	if(__UC_ENV=='DEV'){
		if($tagname=='store'){
			return array(
				'driver' => 'mysql',
				'host' => '10.129.128.14',
				'port' => '3306',
				'username' => 'root',
				'password' => '123qwe',
				'database' => 'app_store',
				'table' => 'a_apps_store'
			);
		}else if($tagname=='userapps'){
			return array(
				'driver' => 'mysql',
				'host' => '10.129.128.14',
				'port' => '3306',
				'username' => 'root',
				'password' => '123qwe',
				'database' => 'app_store',
				'table' => 'a_apps_userapps'
			);
		}else if($tagname=='logs'){
			return array(
				'driver' => 'mysql',
				'host' => '10.129.128.14',
				'port' => '3306',
				'username' => 'root',
				'password' => '123qwe',
				'database' => 'app_store',
				'table' => 'a_apps_logs'
			);
		}else{
			return array(
				'driver' => 'mysql',
				'host' => '10.129.128.14',
				'port' => '3306',
				'username' => 'root',
				'password' => '123qwe',
				'database' => 'app_userapps',
				'table' => 'a_app_userapps'
			);	
			
		}
			
	}else if(__UC_ENV=='TEST'){
		if($tagname=='store'){
			return array(
				'driver' => 'mysql',
				'host' => '10.10.85.4',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => 'sdf2w@!w',
				'database' => 'app_store',
				'table' => 'a_apps_store'
			);
		}else if($tagname=='userapps'){
			return array(
				'driver' => 'mysql',
				'host' => '10.10.85.4',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => 'sdf2w@!w',
				'database' => 'app_store',
				'table' => 'a_apps_userapps'
			);
		}else if($tagname=='logs'){
			return array(
				'driver' => 'mysql',
				'host' => '10.10.85.4',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => 'sdf2w@!w',
				'database' => 'app_store',
				'table' => 'a_apps_logs'
			);
		}else{
			return array(
				'driver' => 'mysql',
				'host' => '10.10.85.4',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => 'sdf2w@!w',
				'database' => 'app_userapps',
				'table' => 'a_app_userapps'
				);
		}
	}else{
        if($tagname=='store'){
			return array(
				'driver' => 'mysql',
				'host' => '10.150.9.5',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => '(qnO-ps:Oi^0F0',
				'database' => 'app_store',
				'table' => 'a_apps_store'
			);
		}else if($tagname=='userapps'){
			return array(
				'driver' => 'mysql',
				'host' => '10.150.9.5',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => '(qnO-ps:Oi^0F0',
				'database' => 'app_store',
				'table' => 'a_apps_userapps'
			);
		}else if($tagname=='logs'){
			return array(
				'driver' => 'mysql',
				'host' => '10.150.9.5',
				'port' => '8066',
				'username' => 'ucdbuser',
				'password' => '(qnO-ps:Oi^0F0',
				'database' => 'app_store',
				'table' => 'a_apps_logs'
			);
		}else{
			return array(
					'driver' => 'mysql',
					'host' => '10.150.9.5',
					'port' => '8066',
					'username' => 'ucdbuser',
					'password' => '(qnO-ps:Oi^0F0',
					'database' => 'app_userapps',
					'table' => 'a_app_userapps'
				);
		}
	}
}
?>